//
//  MLZPLView.m
//  MotherLover
//
//  Created by lanou on 16/1/10.
//  Copyright © 2016年 zj. All rights reserved.
//

#import "MLZPLViewcell.h"

@implementation MLZPLViewcell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        //头像
        _buttonIco = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _buttonIco.frame = CGRectMake(CLandR, CTandB, (KW-CLandR*2)/5,(KW-CLandR*2)/5);
        _buttonIco.backgroundColor = [UIColor blackColor];
        [_buttonIco.layer setCornerRadius:(KW-CLandR*2)/5/2];
        _buttonIco.layer.masksToBounds= YES;
        [self addSubview:_buttonIco];
        //名字
        _lableName = [[UILabel alloc]initWithFrame:CGRectMake(_buttonIco.right+CM, _buttonIco.frame.origin.y, _buttonIco.width*2, _buttonIco.height/2)];
        //_lableName.backgroundColor = [UIColor blackColor];
        _lableName.adjustsFontSizeToFitWidth= YES;
        
        _lableName.textColor= [UIColor redColor];
        [self addSubview:_lableName];
        //时间
        _lableTime = [[UILabel alloc]initWithFrame:CGRectMake(_buttonIco.right+CM, _lableName.bottom+CM, _buttonIco.width*2, _buttonIco.height/2)];
        //_lableTime.backgroundColor = [UIColor blackColor];
        _lableTime.font = [UIFont systemFontOfSize:8];
        _lableTime.textColor= [UIColor grayColor];
        [self addSubview:_lableTime];
        //楼层
        
        _labletype = [[UILabel alloc]initWithFrame:CGRectMake(KW-CLandR-70, _lableName.bottom+CM, 70, _buttonIco.height/2)];
        //_labletype.backgroundColor = [UIColor blackColor];
        _labletype.textColor= [UIColor grayColor];
        [self addSubview:_labletype];
        //内容
        _lableContents = [[UILabel alloc]initWithFrame:CGRectMake(CLandR, _lableTime.bottom+CTandB, KW-CLandR*2 , 100)];
          _lableContents.numberOfLines= -1;
       // _lableContents.backgroundColor = [UIColor blackColor];
        //_lableContents.textColor= [UIColor grayColor];
        [self addSubview:_lableContents];
//回复
        _buttonHF = [UIButton buttonWithType:(UIButtonTypeSystem)];
        _buttonHF.frame = CGRectMake(KW -CLandR- 50 , _lableContents.bottom+CM, 50, 30);
        [_buttonHF setTitle:@"回复" forState:(UIControlStateNormal)];
        [self addSubview:_buttonHF];
               
    }
    
    
    
    
    return self;
    
    
    
    
}
-(void)setModel:(MLZPLModl *)model{


    _lableName.text = model.userName;
    _lableContents.text = model.contents;
    _lableTime.text = model.updatedAt;
    _lableContents.frame = CGRectMake(CLandR, _lableTime.bottom+CTandB, KW-CLandR*2 , 100);
    [_lableContents sizeToFit];
         _buttonHF.frame = CGRectMake(KW -CLandR- 50 , _lableContents.bottom, 50, 30);
    if(model.picture.length==2){
        [_buttonIco setBackgroundImage:[UIImage imageNamed:@"xiaotou"] forState:(UIControlStateNormal )];
    }else{
        [_buttonIco sd_setBackgroundImageWithURL:[NSURL URLWithString:model.picture] forState:(UIControlStateNormal)];
    }

    //NSLog(@"%f",_buttonIco.bottom+_lableContents.height);
    if([_delegate respondsToSelector:@selector(FHheightForHeaderView:)]){
    
        [_delegate FHheightForHeaderView:_buttonIco.bottom+CTandB+_lableContents.frame.size.height+_buttonHF.height+CLandR];
    
    
    }
}
- (void)awakeFromNib {
    // Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
